package com.bk.bands.template;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;

import com.bk.bands.model.Field;


@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
@XmlType(name = "field", namespace = "http://com.bk.docs", propOrder = {
  "position"
})
public abstract class XmlField
{

   private XmlTemplate parentTemplate;

   public XmlField() {} //just to satisfy jaxb

   protected XmlField(XmlTemplate parentTemplate)
   {
      this.parentTemplate = parentTemplate;
   }

   @XmlTransient
   public XmlTemplate getParentTemplate()
   {
      return parentTemplate;
   }

   protected abstract Field delegate();

   @XmlAttribute(required = true)
   public String getLabel()
   {
      return delegate().getLabel();
   }

   public void setLabel(String label)
   {
      delegate().setLabel(label);
   }

   @XmlElement(namespace = "http://com.bk.docs", required = true)
   public XmlPosition getPosition()
   {
      return new XmlPosition(delegate().getPosition(),delegate().getSize());
   }

   public void setPosition(XmlPosition value)
   {
      delegate().setPosition(value.getPosition());
      delegate().setSize(value.getSize());
   }

   public Field getField()
   {
      return delegate();
   }
}
